package com.yanqu.road.entity.unioncampwar;


import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 商帮数据
 */
@FieldTypeAnnotation(tableName = "t_u_union_camp_war", autoSave = true)
public class UserUnionCampWarData extends DataObject {

    @FieldTypeAnnotation(desc = "用户Id", select = true, update = true)
    private long userId;
    @FieldTypeAnnotation(desc = "进攻次数")
    private int attackTimes;
    @FieldTypeAnnotation(desc = "最后一次进攻时间/毫秒")
    private long lastAttackTime;
    @FieldTypeAnnotation(desc = "门客已进攻次数patronsId:times")
    private Map<Integer, Integer> patronsAttckTimesMap = new ConcurrentHashMap<>();
    @FieldTypeAnnotation(desc = "门客付费已进攻次数patronsId:times")
    private Map<Integer, Integer> patronsPayAttckTimesMap = new ConcurrentHashMap<>();
    @FieldTypeAnnotation(desc = "进入主场景的时间")
    private long enterTime;
    @FieldTypeAnnotation(desc = "是否点赞")
    private boolean isWorship;
    @FieldTypeAnnotation(desc = "剩余次数")
    private int leftTimes;
    @FieldTypeAnnotation(desc = "恢复时间/秒")
    private long recoverTime;
    @FieldTypeAnnotation(desc = "周id")
    private int weekId;
    @FieldTypeAnnotation(desc = "藏品加成的次数")
    private int curioTimes;

    public UserUnionCampWarData(long userId) {
        this.userId = userId;
        setInsertOption();
    }

    public UserUnionCampWarData() {
    }

    public long getUserId() {
        return userId;
    }
    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public int getAttackTimes() {
        return attackTimes;
    }
    public void setAttackTimes(int attackTimes) {
        if (this.attackTimes != attackTimes) {
            this.attackTimes = attackTimes;
            setOp(DataStatus.Update);
        }
    }

    public long getLastAttackTime() {
        return lastAttackTime;
    }
    public void setLastAttackTime(long lastAttackTime) {
        if (this.lastAttackTime != lastAttackTime) {
            this.lastAttackTime = lastAttackTime;
            setOp(DataStatus.Update);
        }
    }

    public java.util.Map<java.lang.Integer, java.lang.Integer> getPatronsAttckTimesMap() {
        return patronsAttckTimesMap;
    }
    public void setPatronsAttckTimesMap(ConcurrentHashMap<java.lang.Integer, java.lang.Integer> patronsAttckTimesMap) {
        if (null == patronsAttckTimesMap){
            return;
        }
        if (this.patronsAttckTimesMap == null || !this.patronsAttckTimesMap.equals(patronsAttckTimesMap)) {
            this.patronsAttckTimesMap = patronsAttckTimesMap;
            setOp(DataStatus.Update);
        }
    }

    public void setPatronsAttckTimesMap(Map<Integer, Integer> patronsAttckTimesMap) {
        this.patronsAttckTimesMap = patronsAttckTimesMap;
    }

    public void incPatronsAttackTime(int patronsId) {
        int oldValue = this.patronsAttckTimesMap.getOrDefault(patronsId, 0);
        this.patronsAttckTimesMap.put(patronsId, oldValue + 1);
        setUpdateOption();
    }

    public Map<Integer, Integer> getPatronsPayAttckTimesMap() {
        return patronsPayAttckTimesMap;
    }

    public void setPatronsPayAttckTimesMap(Map<Integer, Integer> patronsPayAttckTimesMap) {
        if (!this.patronsPayAttckTimesMap.equals(patronsPayAttckTimesMap)) {
            this.patronsPayAttckTimesMap = patronsPayAttckTimesMap;
            setOp(DataStatus.Update);
        }
    }

    public void incPatronsPayAttackTime(int patronsId) {
        int oldValue = this.patronsPayAttckTimesMap.getOrDefault(patronsId, 0);
        this.patronsPayAttckTimesMap.put(patronsId, oldValue + 1);
        setUpdateOption();
    }

    public long getEnterTime() {
        return enterTime;
    }

    public void setEnterTime(long enterTime) {
        if (this.enterTime != enterTime) {
            this.enterTime = enterTime;
            setUpdateOption();
        }
    }

    public boolean isWorship() {
        return isWorship;
    }

    public void setWorship(boolean worship) {
        if (this.isWorship != worship) {
            setUpdateOption();
        }
        isWorship = worship;
    }

    public int getLeftTimes() {
        return leftTimes;
    }

    public void setLeftTimes(int leftTimes) {
        if (this.leftTimes != leftTimes) {
            setUpdateOption();
        }
        this.leftTimes = leftTimes;
    }

    public long getRecoverTime() {
        return recoverTime;
    }

    public void setRecoverTime(long recoverTime) {
        if (this.recoverTime != recoverTime) {
            setUpdateOption();
        }
        this.recoverTime = recoverTime;
    }

    public int getWeekId() {
        return weekId;
    }

    public void setWeekId(int weekId) {
        if (this.weekId != weekId) {
            setUpdateOption();
        }
        this.weekId = weekId;
    }

    public int getCurioTimes() {
        return curioTimes;
    }

    public void setCurioTimes(int curioTimes) {
        if(this.curioTimes != curioTimes) {
            this.curioTimes = curioTimes;
            setUpdateOption();
        }
    }
}
